﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:params="http://schemas.codeplex.com/elysium/params"
                    xmlns:primitives="clr-namespace:Elysium.Controls.Primitives;assembly=Elysium" 
                    xmlns:metro="clr-namespace:Elysium.Controls;assembly=Elysium" 
                    xmlns:controls="clr-namespace:Framework.UI.Controls">
    <ResourceDictionary.MergedDictionaries>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Converter.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Brush.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/ElysiumExtra/BorderFix.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <ControlTemplate x:Key="HorizontalProgressBarTemplate" TargetType="{x:Type metro:ProgressBar}" >
        <controls:BorderFix Background="{TemplateBinding Background}" 
                BorderBrush="{TemplateBinding BorderBrush}" 
                BorderThickness="{TemplateBinding BorderThickness}"
                UIElement.ClipToBounds="True" 
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Canvas x:Name="PART_Track">
                <Rectangle x:Name="PART_Indicator" 
                           Fill="{TemplateBinding Foreground}" 
                           StrokeThickness="0" 
                           Canvas.Left="0" 
                           Canvas.Top="0" 
                           Width="{Binding ElementName=PART_Track,Path=ActualWidth}" 
                           Height="{Binding ElementName=PART_Track,Path=ActualHeight}">
                    <FrameworkElement.LayoutTransform>
                        <ScaleTransform ScaleTransform.ScaleX="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Percent}" />
                    </FrameworkElement.LayoutTransform>
                </Rectangle>
                <Canvas x:Name="PART_BusyBar" Canvas.Left="0" Canvas.Top="0" Visibility="Hidden">
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(params:Progress.BusyElementSize),Converter={StaticResource NumberPositiveToNegativeConverter}}" />
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(params:Progress.BusyElementSize),Converter={StaticResource NumberPositiveToNegativeConverter}}" />
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(params:Progress.BusyElementSize),Converter={StaticResource NumberPositiveToNegativeConverter}}" />
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(params:Progress.BusyElementSize),Converter={StaticResource NumberPositiveToNegativeConverter}}" />
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(params:Progress.BusyElementSize),Converter={StaticResource NumberPositiveToNegativeConverter}}" />
                </Canvas>
            </Canvas>
        </controls:BorderFix>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="primitives:ProgressBase.State" Value="Indeterminate" />
                    <Condition Property="IsEnabled" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="PART_Indicator" Value="{Binding ElementName=PART_Indicator,Path=ActualWidth,Converter={StaticResource NumberPositiveToNegativeConverter}}" Property="Canvas.Left" />
                    <Setter TargetName="PART_Indicator" Property="FrameworkElement.LayoutTransform">
                        <Setter.Value>
                            <ScaleTransform ScaleTransform.ScaleX="0.4" />
                        </Setter.Value>
                    </Setter>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="primitives:ProgressBase.State" Value="Busy" />
                    <Condition Property="IsEnabled" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="PART_Indicator" Property="Visibility" Value="Hidden" />
                    <Setter TargetName="PART_BusyBar" Property="Visibility" Value="Visible" />
                </MultiTrigger.Setters>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <ControlTemplate x:Key="VerticalProgressBarTemplate" TargetType="{x:Type metro:ProgressBar}" >
        <controls:BorderFix Background="{TemplateBinding Background}" 
                BorderBrush="{TemplateBinding BorderBrush}" 
                BorderThickness="{TemplateBinding BorderThickness}"
                UIElement.ClipToBounds="True" 
                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
            <Canvas x:Name="PART_Track" 
                    RenderTransformOrigin="0.5,0.5">
                <UIElement.RenderTransform>
                    <ScaleTransform ScaleTransform.ScaleY="-1" />
                </UIElement.RenderTransform>
                <Rectangle x:Name="PART_Indicator" 
                           Fill="{TemplateBinding Foreground}" StrokeThickness="0" Canvas.Left="0" Canvas.Top="0" Width="{Binding ElementName=PART_Track,Path=ActualWidth}" Height="{Binding ElementName=PART_Track,Path=ActualHeight}">
                    <FrameworkElement.LayoutTransform>
                        <ScaleTransform ScaleTransform.ScaleY="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Percent}" />
                    </FrameworkElement.LayoutTransform>
                </Rectangle>
                <Canvas x:Name="PART_BusyBar" Canvas.Left="0" Canvas.Top="0" Visibility="Hidden">
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(params:Progress.BusyElementSize),Converter={StaticResource NumberPositiveToNegativeConverter}}" />
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(params:Progress.BusyElementSize),Converter={StaticResource NumberPositiveToNegativeConverter}}" />
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(params:Progress.BusyElementSize),Converter={StaticResource NumberPositiveToNegativeConverter}}" />
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(params:Progress.BusyElementSize),Converter={StaticResource NumberPositiveToNegativeConverter}}" />
                    <Ellipse Fill="{TemplateBinding Foreground}" StrokeThickness="0" Width="{TemplateBinding params:Progress.BusyElementSize}" Height="{TemplateBinding params:Progress.BusyElementSize}" Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(params:Progress.BusyElementSize),Converter={StaticResource NumberPositiveToNegativeConverter}}" />
                </Canvas>
            </Canvas>
        </controls:BorderFix>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="primitives:ProgressBase.State" Value="Indeterminate" />
                    <Condition Property="IsEnabled" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="PART_Indicator" Value="{Binding ElementName=PART_Indicator,Path=ActualHeight,Converter={StaticResource NumberPositiveToNegativeConverter}}" Property="Canvas.Top" />
                    <Setter TargetName="PART_Indicator" Property="FrameworkElement.LayoutTransform">
                        <Setter.Value>
                            <ScaleTransform ScaleTransform.ScaleY="0.4" />
                        </Setter.Value>
                    </Setter>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="primitives:ProgressBase.State" Value="Busy" />
                    <Condition Property="IsEnabled" Value="True" />
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter TargetName="PART_Indicator" Property="Visibility" Value="Hidden" />
                    <Setter TargetName="PART_BusyBar" Property="Visibility" Value="Visible" />
                </MultiTrigger.Setters>
            </MultiTrigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
    <Style x:Key="{x:Type metro:ProgressBar}" TargetType="{x:Type metro:ProgressBar}" >
        <Setter Property="Background" Value="{StaticResource HighlightBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="{StaticResource AccentBrush}" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Style.Triggers>
            <Trigger Property="primitives:ProgressBase.State" Value="Busy">
                <Setter Property="Background" Value="{x:Null}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Foreground" Value="{StaticResource DisabledBrush}" />
            </Trigger>
            <Trigger Property="metro:ProgressBar.Orientation" Value="Horizontal">
                <Setter Property="MinHeight" Value="2" />
                <Setter Property="Height" Value="4" />
                <Setter Property="MaxHeight" Value="8" />
                <Setter Property="MinWidth" Value="2" />
                <Setter Property="Template" Value="{StaticResource HorizontalProgressBarTemplate}" />
            </Trigger>
            <Trigger Property="metro:ProgressBar.Orientation" Value="Vertical">
                <Setter Property="MinHeight" Value="2" />
                <Setter Property="MinWidth" Value="2" />
                <Setter Property="Width" Value="4" />
                <Setter Property="MaxWidth" Value="8" />
                <Setter Property="Template" Value="{StaticResource VerticalProgressBarTemplate}" />
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>